/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ddnsserver;
import java.util.Vector;
/**
 *
 * @author Do Viet Trung
 */
public class AccountInfo
{
    private String username;
    private String password;
    private Vector<String>allowDomain;

    public AccountInfo()
    {
        username = "";
        password = "";
        allowDomain = new Vector<String>();
    }
    public AccountInfo(String usr, String passwd, Vector<String> allow_domain)
    {
        username = usr;
        password = passwd;
        allowDomain = new Vector<String>();
        for(int i = 0; i < allow_domain.size(); i++)
        {
            allowDomain.add(allow_domain.elementAt(i));
        }
    }
    public boolean verify(String username, String passwd)
    {
        if(this.username.equals(username) && this.password.equals(passwd))
        {
            return true;
        }
        return false;
    }
    public boolean checkPermission(String host)
    {
        if(host == null || host.equals(""))return false;
        for(int i = 0; i < allowDomain.size(); i++)
        {
            if(allowDomain.elementAt(i).equals(host))
            {
                return true;
            }
        }
        return false;
    }
    public String getUsername()
    {
        return username;
    }
    public String getPassword()
    {
        return password;
    }
    public Vector<String> getListAllowDomains()
    {
        return allowDomain;
    }

    public void setUsername(String usr)
    {
        if(usr != null)
        {
            username = usr;
        }
    }
     public void setPassword(String passwd)
    {
        if(passwd != null)
        {
            password = passwd;
        }
    }
     public void addAllowDomain(String domain)
     {
         if(domain != "")
         {
            allowDomain.add(domain);
        }
     }
     public int getAllowDomainCount()
     {
         return allowDomain.size();
     }
     public String getAllowDomainIndex(int index)
    {
         if(index >= 0)
         {
            return allowDomain.elementAt(index);
        }
         return null;
     }
}
